import * as service from "@/service";
import { IMother } from "./interface";
const mother: IMother = {
  namespaced: true,
  state: {
    list: [],
    cate: [],
  },
  actions: {
    async getMotherList({ commit }) {
      const result = await service.fetchMotherList();
      const action = {
        type: "GETMOTHER",
        payload: result?.data?.categoryRespVOS,
      };
      commit(action);
    },
    async getMotherCate({ commit }, { categoryId }) {
      const result = await service.fetchMotherCate(categoryId);
      const action = {
        type: "GETMotherCate",
        payload: result?.data?.lists,
      };
      commit(action);
    },
  },
  mutations: {
    GETMOTHER(state, action) {
      state.list = action.payload;
    },
    GETMotherCate(state, action) {
      state.cate = action.payload;
    },
  },
};
export default mother;
